package org.taotao.jedis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisUtils {
    private final static JedisPool POOL;
    
    static{
      //1.设置连接池的配置对象
        JedisPoolConfig config = new JedisPoolConfig();
        //2.设置池中最大连接数【可选】
        config.setMaxTotal(50);
        //3.设置空闲时池中保有的最大连接数【可选】
        config.setMaxIdle(10);
        //4.设置连接池对象
        POOL = new JedisPool(config,"192.168.170.131",6379);
    }
    
    public static Jedis getJedis(){
        return POOL.getResource();
    }
}
